﻿<UserControl x:Class="SfdClient.View.AzureBrowserView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:Converter="clr-namespace:SfdClient.Converter" xmlns:ViewModel1="clr-namespace:SfdClient.ViewModel"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             DataContext="{Binding Source={StaticResource locator}, Path=AzureBrowserViewModel}" Background="Transparent">
    <UserControl.Resources>
        <!--Converters-->
		<Converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <Converter:AzureBrowserItemToImageConverter x:Key="AzureBrowserItemToImageConverter"/>
        <!--Templates du Listview-->
        <DataTemplate x:Key="AzureBrowerItemTemplate" DataType="{x:Type ViewModel1:AzureBrowserItem}">
            <StackPanel Orientation="Horizontal">
                <Image x:Name="image" Source="{Binding Converter={StaticResource AzureBrowserItemToImageConverter}}" Margin="0,5,5,5" Width="{DynamicResource ListViewImageWidth}" Height="{DynamicResource ListViewImageHeight}"/>
                <TextBlock Text="{Binding FriendlyName}" VerticalAlignment="Center"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="LastModificationTemplate" DataType="{x:Type ViewModel1:AzureBrowserItem}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding LastModification, StringFormat=\{0:G\}}" VerticalAlignment="Center"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="LengthTemplate" DataType="{x:Type ViewModel1:FolderBrowserItem}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=FriendlyLength}" VerticalAlignment="Center"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width="Auto"/>
    		<ColumnDefinition Width="     *"/>
    	</Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock  Text="{Binding Project.ContainerName, Mode=OneWay}" Style="{DynamicResource TitleStyle}" Grid.Column="1"   />

        <ListView ItemsSource="{Binding AzureBrowserItems}" Grid.Row="2" x:Name="lv" Grid.ColumnSpan="2">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="{Binding [AzureBrowserView_Nom], Source={StaticResource localizer}}" Width="150" CellTemplate="{DynamicResource AzureBrowerItemTemplate}"/>
                    <GridViewColumn Header="{Binding [AzureBrowserView_Modifie], Source={StaticResource localizer}}" Width="150" CellTemplate="{DynamicResource LastModificationTemplate}"/>
                    <GridViewColumn Header="{Binding [AzureBrowserView_Taille], Source={StaticResource localizer}}" Width="150" CellTemplate="{DynamicResource LengthTemplate}"/>
                </GridView>
            </ListView.View>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDoubleClick">
                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding CurrentFolderChangedCommand}" CommandParameter="{Binding SelectedItem, ElementName=lv}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ListView.Background>
                <SolidColorBrush />
            </ListView.Background>
        </ListView>

        <Image Source="{DynamicResource Cloud}" Stretch="Fill"/>

        <Border x:Name="bdWorking" BorderBrush="Black" BorderThickness="1" Grid.RowSpan="4" Grid.ColumnSpan="2" Background="#33FFFFFF" Visibility="{Binding IsWorking, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
        	<ProgressBar Style="{DynamicResource ProgressBarBusyIndicator}" IsIndeterminate="True" Width="70" Height="70" />
        </Border>

    </Grid>
</UserControl>
